﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace Adams.Admin.Presentation.Controllers
{
    [Authorize]
    [EnsureSsl]
    public class MembershipController : Controller
    {
        [AppendLayoutViewModel]
        public ActionResult Index()
        {

            var model = Business.Membership.Index.PageLoad();
            ViewBag.Message = Request["msg"];
            return View(model);
        }

        public JsonResult GridLoad(DataTransfer.GridLoadInput gridinput)
        {
            var model = Business.Membership.Index.GridLoad(gridinput);
            return Json(model);
        }

        [AppendLayoutViewModel]
        public ActionResult CreateMember(int id)
        {
            
            var model = Business.Membership.CreateMember.PageLoad(id);
            return View(model);
        }

        public JsonResult SaveMember(Adams.Admin.DataTransfer.Membership.CreateMember.FormInput input)
        {
            var model = Business.Membership.CreateMember.SaveMember(input);
            return Json(model);
        }

        public JsonResult GetMembersBySearch(string term)
        {
            var model = Business.Membership.Common.GetMembersBySearch(term);
            return Json(model, JsonRequestBehavior.AllowGet);
        }
    }
}
